using System;

namespace SharpMud.MudLib.SAMPLE.Net.SessionStates.PlayerCreation
{
	public class ConcludeCreation : SessionStateBase
	{
		private const string
			Msg		=	"Yay Character creation is over!! (Short, eh?)";

		private bool _MsgSent;

		public ConcludeCreation()
		{
			_MsgSent=false;
		}

		public override string StateID
		{
			get
			{
				return "ConcludeCreation";
			}
		}

		public override void Pulse()
		{
			if(!StillActive)
				return;
			if(!_MsgSent)
			{
				Session.CharacterInCreation.Location = new SharpMud.MudLib.SAMPLE.Environment.RoomID(0,null);

				Session.WriteLine();
				Session.WriteLine(Msg,true);
				Session.WriteLine();
				Session.MigrateCreationCharacter();
				Session.Write("Saving your character...",true);
				Session.CurrentCharacter.Save();
				Session.WriteLine("DONE!",true);
				Session.WriteLine();
				
				_MsgSent = true;
			}
			SetInactive();
			Session.SessionState.Clear();
			//Supposed to start the player with a "New Player" sequence of states
			Session.SessionState.Push(new SessionStates.PutInWorld());
			return;
		}

	}
}
